<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button onclick="createObj()">使用构造函数创建对象</button>
    
    <script>
        /**
        使用构造函数创建对象
        声明构造函数
         this.stuId:表示当前构造函数内部存在一个指定的属性
        */
        function Student(stuId,stuName,stuAge){
            //对象中的属性
           this.stuId = stuId;
           this.stuName = stuName;
           this.stuAge = stuAge;     
        }

        function createObj(){
            let student = new Student(1001,"小花",20);
            console.log(student);
            let student1 = new Student();
            console.log(student1);
            student1.stuId=1002;
            student1.stuName="小明";
            student1.stuAge = 20;
            console.log(student1);
        }
    </script>
</body>
</html>